const deleteObjProperty = (arr, obj) => {
  arr.forEach((item) => {
    delete obj[item]
  })
}

const deleteSchoolConfig = ['picUrlArr', 'iconUrl', 'schoolName']
const deleteUserInfo = ['cardNumber', 'identityTitle', 'schoolCode']

Page({
  data: {
    path: ''
  },
  onLoad (options) {
    try {
      const { path, courseId, title } = options
      // const path = 'http://192.168.7.119:3000/#/activity'
      // const path = 'http://xwx.gzzmedu.com:6999/x-mai/#/activity'
      const userInfo = wx.getStorageSync('userInfo')
      const schoolConfig = wx.getStorageSync('schoolConfig')
      const token = wx.getStorageSync('token')

      deleteObjProperty(deleteSchoolConfig, schoolConfig)
      deleteObjProperty(deleteUserInfo, userInfo)
      const query = encodeURIComponent(JSON.stringify({ userInfo, schoolConfig, token, courseId, title }))
      const url = `${path}?query=${query}&t=${new Date().getTime()}`
      console.log(url.length, url)
      this.setData({
        path: url
      })
    } catch (error) {
      wx.showToast({
        title: '参数错误',
        icon: 'none',
        duration: 2000
      })
      wx.navigateBack({ delta: 1 })
    }
  },
  getMsgHandle (e) {
    console.log(e)
  }
})
